
<!DOCTYPE html>
<html lang="zh">
<head>
    <title><{:isset($webConf.bs_title)?$webConf.bs_title:'BS后台管理'}></title>
    <{include file="public/header"}>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
    <!-- Font Awesome -->
    <!-- daterange picker -->
   <!-- <link rel="stylesheet" href="/static/adminlte/plugins/daterangepicker/daterangepicker.css">-->
    <!-- iCheck for checkboxes and radio inputs -->
    <link rel="stylesheet" href="/static/adminlte/plugins/icheck-bootstrap/icheck-bootstrap.min.css">

    <!-- Tempusdominus Bootstrap 4 -->
    <link rel="stylesheet" href="/static/adminlte/plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
    <!-- Select2 -->
    <link rel="stylesheet" href="/static/adminlte/plugins/select2/css/select2.min.css">
    <link rel="stylesheet" href="/static/adminlte/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">
    <!-- Bootstrap4 Duallistbox -->
    <link rel="stylesheet" href="/static/adminlte/plugins/bootstrap4-duallistbox/bootstrap-duallistbox.min.css">
    <!-- BS Stepper -->
    <link rel="stylesheet" href="/static/adminlte/plugins/bs-stepper/css/bs-stepper.min.css">
    <!-- dropzonejs -->
    <link rel="stylesheet" href="/static/adminlte/plugins/dropzone/min/dropzone.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="/static/adminlte/css/adminlte.min.css">

    <{include file="public/data_tables_css"}>
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<!-- Site wrapper -->
<div class="wrapper">
    <!-- 顶部导航 -->
    <{include file="public/navbar"}>
    <!--左侧菜单-->
    <{include file="public/sidebar"}>

    <div class="content-wrapper">
        <!-- 面包屑导航 -->
        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">

                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="<{:url('/admin/index/index')}>">首页</a></li>
                            <li class="breadcrumb-item"><a href="#">系统设置</a></li>
                            <li class="breadcrumb-item active">IP黑名单配置</li>
                        </ol>
                    </div>
                </div>
            </div>
        </section>

        <!-- 内容区-->
        <section class="content">
            <div class="container-fluid">

                <!--阿里云start-->
                <div class="card card-purple">
                    <div class="card-header">
                        <h3 class="card-title">IP黑名单列表</h3>

                        <div class="card-tools">
                            <button type="button" class="btn btn-tool" data-card-widget="collapse">
                                <i class="fas fa-minus"></i>
                            </button>
                            <button type="button" class="btn btn-tool" data-card-widget="remove">
                                <i class="fas fa-times"></i>
                            </button>
                        </div>
                    </div>

                    <div class="card-body" style="display: block;">
                        <div class="row">
                            <div class="col-md-12">
                                <form method="post" action="<{:url('/admin/system.index/ip_blacklist_action')}>" id="check-form">


                                    <div class="form-group">
                                        <label for="ip_blacklist">添加IP</label>
                                        <input name="ip" placeholder="添加新的ip" id="ip_blacklist" class="form-control" value=""/>
                                        <input type="hidden" name="ac" value="add">
                                        <span class="bs-red">如127.0.0.1</span>
                                    </div>
                                </form>
                                <button type="button" onclick="sub()" class="btn btn-primary">提交保存</button>
                            </div>

                        </div>
                        <table id="my_table" class="table table-bordered table-striped bs-top-10">
                            <thead>
                            <tr>
                                <th>IP黑名单数据库</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <{if !empty($data)}>
                            <{foreach $data as $item}>
                            <tr>
                                <td><{$item}></td>


                                <td>

                                    <span class="btn  btn-danger btn-xs " onclick="del(this)" data-ip="<{$item}>"   title="删除">删除</span>

                                </td>

                            </tr>
                            <{/foreach}>
                            <{/if}>



                            </tbody>
                            <tfoot>


                            </tfoot>
                        </table>

                        <div class="alert alert-warning">以下是自动捕获的可疑IP名单，每秒请求同一个接口数据多次的IP，超过10的添加到这里，超过<a  style="color: blue !important;" href="safe.html">【后台配置的次数】</a>自动添加黑名单。</div>
                        <table id="my_table1" class="table table-bordered table-striped bs-top-10">
                            <thead>
                            <tr>
                                <th>可疑请求IP列表</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <{if !empty($limitData)}>
                            <{foreach $limitData as $v}>
                            <tr>
                                <td><{$v}></td>


                                <td>

                                    <span class="btn  btn-danger btn-xs " onclick="add_black(this)" data-ip="<{$v}>"   title="拉黑">拉黑</span>

                                    <span class="btn  btn-success btn-xs bs-left-10 " onclick="add_black(this,'remove')" data-ip="<{$v}>"   title="删除">删除</span>

                                </td>

                            </tr>
                            <{/foreach}>
                            <{/if}>



                            </tbody>
                            <tfoot>


                            </tfoot>
                        </table>
                    </div>

                    <div class="card-footer" style="display: block;">

                    </div>
                </div>
            </div>

        </section>
    </div>

    <{include file="public/copyright"}>


</div>
<!-- ./wrapper -->

<{include file="public/footer"}>
<!-- DataTables  & Plugins -->
<{include file="public/data_tables"}>
<script>

    function sub(){
        layer.confirm('确定提交保存吗',{title:0},function() {
            form_submit([],"<{:url('ip_blacklist')}>",false,false,'check-form')
        })
    }
    function del(obj) {
        var ip = $(obj).data('ip')
        layer.confirm('确定要删除吗？',{title:0},function () {
            sendData("<{:url('ip_blacklist_action')}>",{ac:'del',ip:ip},function (res) {
                if (res.code==0){
                    $(obj).parent('td').parent('tr').remove()
                }
            })
        })
    }
    function add_black(obj,type) {
        var ip = $(obj).data('ip')
        layer.confirm('确定要'+(type=='remove'?'移除':'添加黑名单')+'吗？',{title:0},function () {
            sendData("<{:url('ip_blacklist_action')}>",{ac:'add',type:type,ip:ip,f:'limit_list'},function (res) {
                if (res.code==0){
                    if (type=='remove'){
                        $(obj).parent('td').parent('tr').remove()
                    }else {
                        location.reload();
                    }

                }
            })
        })
    }
$(function () {


    $("#my_table,#my_table1").DataTable({
        "ordering": true,//禁用排序
        "responsive": true,
        "lengthChange": false,
        "autoWidth": false,
        //"buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"],
         "pageLength": 10,         //初始化显示几条数据
        //serverSide: true, // use local process instead of server
        // bFilter: true, // show top right search input box.
        bPaginate: true,//是否开启分页
        iDisplayLength: 10, //默认显示的记录数
        bInfo: true,//是否显示页脚信息，DataTables插件左下角显示记录数
    }).buttons().container().appendTo('#my_table_wrapper .col-md-6:eq(0)');

});
</script>

</body>
</html>
